<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2018/10/26
 * Time: 14:46
 */

namespace app\api\model;


use app\api\validate\IdsCollection;

class Theme extends BaseModel
{

    public function topicImg(){
        return $this->belongsTo('Image','topic_img_id','id');
    }

    public function headImg(){
        return $this->belongsTo('Image','head_img_id','id');
    }

    public function products(){
        return $this->belongsToMany('Product','theme_product','product_id','theme_id');
    }

    public static function getThemeProducts($id){
        $theme = self::with('products,topicImg,headImg')->get($id);
        return $theme;
    }

}